/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
  @endpointMap = {
    ap-northeast-1 = 'plaso-classroom.aliyuncs.com',
    ap-northeast-2-pop = 'plaso-classroom.aliyuncs.com',
    ap-south-1 = 'plaso-classroom.aliyuncs.com',
    ap-southeast-1 = 'plaso-classroom.aliyuncs.com',
    ap-southeast-2 = 'plaso-classroom.aliyuncs.com',
    ap-southeast-3 = 'plaso-classroom.aliyuncs.com',
    ap-southeast-5 = 'plaso-classroom.aliyuncs.com',
    cn-beijing = 'plaso-classroom.aliyuncs.com',
    cn-beijing-finance-1 = 'plaso-classroom.aliyuncs.com',
    cn-beijing-finance-pop = 'plaso-classroom.aliyuncs.com',
    cn-beijing-gov-1 = 'plaso-classroom.aliyuncs.com',
    cn-beijing-nu16-b01 = 'plaso-classroom.aliyuncs.com',
    cn-chengdu = 'plaso-classroom.aliyuncs.com',
    cn-edge-1 = 'plaso-classroom.aliyuncs.com',
    cn-fujian = 'plaso-classroom.aliyuncs.com',
    cn-haidian-cm12-c01 = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-finance = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'plaso-classroom.aliyuncs.com',
    cn-hangzhou-test-306 = 'plaso-classroom.aliyuncs.com',
    cn-hongkong = 'plaso-classroom.aliyuncs.com',
    cn-hongkong-finance-pop = 'plaso-classroom.aliyuncs.com',
    cn-huhehaote = 'plaso-classroom.aliyuncs.com',
    cn-huhehaote-nebula-1 = 'plaso-classroom.aliyuncs.com',
    cn-north-2-gov-1 = 'plaso-classroom.aliyuncs.com',
    cn-qingdao = 'plaso-classroom.aliyuncs.com',
    cn-qingdao-nebula = 'plaso-classroom.aliyuncs.com',
    cn-shanghai = 'plaso-classroom.aliyuncs.com',
    cn-shanghai-et15-b01 = 'plaso-classroom.aliyuncs.com',
    cn-shanghai-et2-b01 = 'plaso-classroom.aliyuncs.com',
    cn-shanghai-finance-1 = 'plaso-classroom.aliyuncs.com',
    cn-shanghai-inner = 'plaso-classroom.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'plaso-classroom.aliyuncs.com',
    cn-shenzhen = 'plaso-classroom.aliyuncs.com',
    cn-shenzhen-finance-1 = 'plaso-classroom.aliyuncs.com',
    cn-shenzhen-inner = 'plaso-classroom.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'plaso-classroom.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'plaso-classroom.aliyuncs.com',
    cn-wuhan = 'plaso-classroom.aliyuncs.com',
    cn-wulanchabu = 'plaso-classroom.aliyuncs.com',
    cn-yushanfang = 'plaso-classroom.aliyuncs.com',
    cn-zhangbei = 'plaso-classroom.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'plaso-classroom.aliyuncs.com',
    cn-zhangjiakou = 'plaso-classroom.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'plaso-classroom.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'plaso-classroom.aliyuncs.com',
    eu-central-1 = 'plaso-classroom.aliyuncs.com',
    eu-west-1 = 'plaso-classroom.aliyuncs.com',
    eu-west-1-oxs = 'plaso-classroom.aliyuncs.com',
    me-east-1 = 'plaso-classroom.aliyuncs.com',
    rus-west-1-pop = 'plaso-classroom.aliyuncs.com',
    us-east-1 = 'plaso-classroom.aliyuncs.com',
    us-west-1 = 'plaso-classroom.aliyuncs.com',
  };
  checkConfig(config);
  @endpoint = getEndpoint('plaso_online_class', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model DataCallbackRequest {
  recordId?: string(name='RecordId'),
  teacherId?: string(name='TeacherId'),
  signature?: string(name='Signature'),
  validBegin?: long(name='ValidBegin'),
  appId?: string(name='AppId'),
  topic?: string(name='Topic'),
  meetingId?: string(name='MeetingId'),
  validTime?: long(name='ValidTime'),
  beginTime?: long(name='BeginTime'),
  endTime?: long(name='EndTime'),
  cover?: string(name='Cover'),
  duration?: string(name='Duration'),
  listenerCount?: long(name='ListenerCount'),
  userCount?: long(name='UserCount'),
}

model DataCallbackResponseBody = {
  msg?: string(name='Msg'),
  code?: int32(name='Code'),
}

model DataCallbackResponse = {
  headers: map[string]string(name='headers'),
  body: DataCallbackResponseBody(name='body'),
}

async function dataCallback(request: DataCallbackRequest): DataCallbackResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return dataCallbackWithOptions(request, headers, runtime);
}

async function dataCallbackWithOptions(request: DataCallbackRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DataCallbackResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.recordId)) {
    query.RecordId = request.recordId;
  }
  if (!Util.isUnset(request.teacherId)) {
    query.TeacherId = request.teacherId;
  }
  if (!Util.isUnset(request.signature)) {
    query.Signature = request.signature;
  }
  if (!Util.isUnset(request.validBegin)) {
    query.ValidBegin = request.validBegin;
  }
  if (!Util.isUnset(request.appId)) {
    query.AppId = request.appId;
  }
  if (!Util.isUnset(request.topic)) {
    query.Topic = request.topic;
  }
  if (!Util.isUnset(request.meetingId)) {
    query.MeetingId = request.meetingId;
  }
  if (!Util.isUnset(request.validTime)) {
    query.ValidTime = request.validTime;
  }
  if (!Util.isUnset(request.beginTime)) {
    query.BeginTime = request.beginTime;
  }
  if (!Util.isUnset(request.endTime)) {
    query.EndTime = request.endTime;
  }
  if (!Util.isUnset(request.cover)) {
    query.Cover = request.cover;
  }
  if (!Util.isUnset(request.duration)) {
    query.Duration = request.duration;
  }
  if (!Util.isUnset(request.listenerCount)) {
    query.ListenerCount = request.listenerCount;
  }
  if (!Util.isUnset(request.userCount)) {
    query.UserCount = request.userCount;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('DataCallback', '2021-4-20', 'HTTPS', 'POST', 'AK', `/plaso/datacallback`, 'json', req, runtime);
}

model EndCallbackRequest {
  opTime?: long(name='OpTime'),
  signature?: string(name='Signature'),
  validBegin?: long(name='ValidBegin'),
  appId?: string(name='AppId'),
  meetingId?: string(name='MeetingId'),
  validTime?: long(name='ValidTime'),
  newEndTime?: long(name='NewEndTime'),
}

model EndCallbackResponseBody = {
  msg?: string(name='Msg'),
  code?: int32(name='Code'),
}

model EndCallbackResponse = {
  headers: map[string]string(name='headers'),
  body: EndCallbackResponseBody(name='body'),
}

async function endCallback(request: EndCallbackRequest): EndCallbackResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return endCallbackWithOptions(request, headers, runtime);
}

async function endCallbackWithOptions(request: EndCallbackRequest, headers: map[string]string, runtime: Util.RuntimeOptions): EndCallbackResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.opTime)) {
    query.OpTime = request.opTime;
  }
  if (!Util.isUnset(request.signature)) {
    query.Signature = request.signature;
  }
  if (!Util.isUnset(request.validBegin)) {
    query.ValidBegin = request.validBegin;
  }
  if (!Util.isUnset(request.appId)) {
    query.AppId = request.appId;
  }
  if (!Util.isUnset(request.meetingId)) {
    query.MeetingId = request.meetingId;
  }
  if (!Util.isUnset(request.validTime)) {
    query.ValidTime = request.validTime;
  }
  if (!Util.isUnset(request.newEndTime)) {
    query.NewEndTime = request.newEndTime;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('EndCallback', '2021-4-20', 'HTTPS', 'POST', 'AK', `/plaso/roa`, 'json', req, runtime);
}

